package com.sms.smscode.room;

import androidx.room.Database;
import androidx.room.Room;

import com.sms.smscode.ZApp;


@Database(entities = {SmsEntity.class}, version = 1)
public abstract class SmsDatabase extends androidx.room.RoomDatabase {
    //定义了几个Dao注解的累，这里就写几个抽象方法
    public abstract SmsDao smsDao();

    private static SmsDatabase instance;

    public static SmsDatabase getInstance() {
        if (instance == null) {
            synchronized (SmsDatabase.class) {
                if (instance == null) {
                    instance = Room.databaseBuilder(ZApp.getInstance().getBaseContext(), SmsDatabase.class, "room.db")
                            .build();
                }
            }
        }
        return instance;
    }
}
